﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Model;
namespace UI
{
    public partial class 餐桌批量添加 : Form
    {
        public 餐桌批量添加()
        {
            InitializeComponent();
        }
         主界面 f;
         public 餐桌批量添加(主界面 f)
        {
            InitializeComponent();
            this.f = f;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 餐桌批量添加_Load(object sender, EventArgs e)
        {
            DataSet ds = 餐桌信息BLL.GaoJIBanDing();
            this.comboBox1.DataSource = ds.Tables[0];
            this.comboBox1.ValueMember = "RTID";
            this.comboBox1.DisplayMember = "RTName";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text =="" || textBox3.Text=="" || textBox4.Text =="")
            {
                MessageBox.Show("请填写完整信息");
                return;
            }
            string Name = textBox1.Text;
            int count = 0;
            int j = int.Parse(textBox2.Text);
            餐桌Model.TableArea = textBox4.Text;
            餐桌Model.RTID = this.comboBox1.SelectedValue.ToString();
            string a = "";
            for (int i = j; i <= int.Parse(textBox3.Text); i++)
            {
                if (i >= 10)
                {
                    a = "0";
                }
                else
                {
                    a = "00";
                }
                餐桌Model.TableName = Name + a + i;

                count = 餐桌信息BLL.Adds();
            }
            if (count > 0)
            {
                MessageBox.Show("添加成功");
                f.Zz();
            }
            else
            {
                MessageBox.Show("添加失败");
            }
        }
    }
}
